// subHoliday/holidayList/holiday_list.js
const appg = getApp().globalData
Page({

  /**
   * 页面的初始数据
   */
  data: {
    keyvalue: null,
    // 请假列表
    holidayList: [],
    page: {
      pageNum: 1,
      pageSize: 100,
      totalCount: 0
    },
    userInfo: {
      uid: appg.userInfo.id,
      identity_ID: appg.userInfo.identity_ID,
      position_ID: appg.userInfo.position_ID
    }
  },
  // 去请假详细
  to_holiday_detail(e) {
    console.log(e);
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/subHoliday/holidayDetail/holiday_detail?id='+id,
    })
  },
  // 获取请假列表
  async getHolidayList() {
    wx.showLoading({
      title: '加载中',
    })
    try {
      const params = {
        uid: this.data.userInfo.uid,
        identity_ID: this.data.userInfo.identity_ID,
        position_ID: this.data.userInfo.position_ID,
        ...this.data.page,
        school_ID:appg.userInfo.school_ID
      }
      const json = await getApp().$axios("/getLeaveList", "POST", params)
      wx.hideLoading()
      if (json.status !== 200) {
        wx.showToast({
          title: json.data,
          icon: 'none'
        })
        return
      }
      this.setData({
        holidayList: json.data
      })
    } catch (error) {
      wx.showToast({
        title: error.msg,
        icon: 'error'
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

    this.setData({
      userInfo: {
        uid: appg.userInfo.id,
        identity_ID: appg.userInfo.identity_ID,
        position_ID: appg.userInfo.position_ID
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getHolidayList()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})